using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Home_ManagePlacementCategory : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnAddNewAttendancePattern_Click(object sender, EventArgs e)
    {
        if (this.txtNewAttendancePatternName.Text.Length > 0)
        {
            this.lblNewAttendancePatternMessage.Text = string.Empty;

            PlacementManager.AttendancePatternComponent oAPC = new PlacementManager.AttendancePatternComponent();
            PlacementManager.AttendancePattern oNewAP = new PlacementManager.AttendancePattern();
            oNewAP.AttendancePatternName = this.txtNewAttendancePatternName.Text.Trim();
            oNewAP.CreatedBy = User.Identity.Name;
            oNewAP.DateCreated = DateTime.Now;
            oNewAP.DateUpdated = DateTime.Now;
            oNewAP.DivisionId = Int32.Parse(Session["DivisionId"].ToString());
            oNewAP.IsActive = true;
            oNewAP.UpdatedBy = User.Identity.Name;
            oAPC.Insert(oNewAP);

            this.gvAttendancePatterns.DataBind();
            this.txtNewAttendancePatternName.Text = string.Empty;
        }
        else
        {
            this.lblNewAttendancePatternMessage.Text = "Please enter an attendance pattern name.";
        }
    }
    protected void gvAttendancePatterns_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        PlacementManager.AttendancePatternComponent oAPC = new PlacementManager.AttendancePatternComponent();
        PlacementManager.AttendancePattern oAP = oAPC.SelectOne(Int32.Parse(this.gvAttendancePatterns.DataKeys[e.RowIndex].Value.ToString()));

        e.NewValues.Add("AttendancePatternId", oAP.AttendancePatternId);
        e.NewValues.Add("CreatedBy", oAP.CreatedBy);
        e.NewValues.Add("DateCreated", oAP.DateCreated);
        e.NewValues.Add("DivisionId", oAP.DivisionId);
        e.NewValues.Add("DateUpdated", DateTime.Now);
        e.NewValues.Add("UpdatedBy", User.Identity.Name);
        
    }
}
